<!DOCTYPE html>
<html>
<head>
    

    

    



    <meta charset="utf-8">
    
    
    
    
    <title>混合加密算法(RSA和DES) | Junxin&#39;s Blog</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="网络安全">
    <meta name="description" content="混合加密的理由 由于随着计算机系统能力的不断发展，DES的安全性比它刚出现时会弱得多，追溯历史破解DES的案例层出不穷，一台实际的机器可以在数天内破解DES是让某些人相信他们不能依赖DES的安全性的唯一方法。而相对于DES，RSA的安全性则相对高些，虽然破解RSA的案例也有，但其所付出的代价是相对大的(相对DES)，如今RSA的密钥也在升级，这说明破解RSA的难度也在增大。 在RSA加解密算法中提">
<meta name="keywords" content="网络安全">
<meta property="og:type" content="article">
<meta property="og:title" content="混合加密算法(RSA和DES)">
<meta property="og:url" content="http://aixiaodenanhai.gitee.io/blog/2018/04/27/混合加密算法(RSA和DES).html">
<meta property="og:site_name" content="Junxin&#39;s Blog">
<meta property="og:description" content="混合加密的理由 由于随着计算机系统能力的不断发展，DES的安全性比它刚出现时会弱得多，追溯历史破解DES的案例层出不穷，一台实际的机器可以在数天内破解DES是让某些人相信他们不能依赖DES的安全性的唯一方法。而相对于DES，RSA的安全性则相对高些，虽然破解RSA的案例也有，但其所付出的代价是相对大的(相对DES)，如今RSA的密钥也在升级，这说明破解RSA的难度也在增大。 在RSA加解密算法中提">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2018-04-28T15:45:00.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="混合加密算法(RSA和DES)">
<meta name="twitter:description" content="混合加密的理由 由于随着计算机系统能力的不断发展，DES的安全性比它刚出现时会弱得多，追溯历史破解DES的案例层出不穷，一台实际的机器可以在数天内破解DES是让某些人相信他们不能依赖DES的安全性的唯一方法。而相对于DES，RSA的安全性则相对高些，虽然破解RSA的案例也有，但其所付出的代价是相对大的(相对DES)，如今RSA的密钥也在升级，这说明破解RSA的难度也在增大。 在RSA加解密算法中提">
    
        <link rel="alternate" type="application/atom+xml" title="Junxin&#39;s Blog" href="/blog/atom.xml">
    
    <link rel="shortcut icon" href="/blog/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/blog/img/brand.jpg)">
      <div class="brand">
        <a href="/blog/" class="avatar waves-effect waves-circle waves-light">
          <img src="/blog/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">何俊鑫</h5>
          <a href="mailto:doubihah@foxmail.com" title="doubihah@foxmail.com" class="mail">doubihah@foxmail.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/blog/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/blog/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                Archives
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/blog/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                Tags
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/hejx1" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://gitee.com/aixiaodenanhai" target="_blank" >
                <i class="icon icon-lg icon-link"></i>
                码云
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">混合加密算法(RSA和DES)</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">混合加密算法(RSA和DES)</h1>
        <h5 class="subtitle">
            
                <time datetime="2018-04-26T16:00:00.000Z" itemprop="datePublished" class="page-time">
  2018-04-27
</time>


            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#混合加密的理由"><span class="post-toc-number">1.</span> <span class="post-toc-text">混合加密的理由</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#实现方式"><span class="post-toc-number">2.</span> <span class="post-toc-text">实现方式</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#实现例子"><span class="post-toc-number">3.</span> <span class="post-toc-text">实现例子</span></a></li></ol>
        </nav>
    </aside>


<article id="post-混合加密算法(RSA和DES)"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">混合加密算法(RSA和DES)</h1>
        <div class="post-meta">
            <time class="post-time" title="2018-04-27 00:00:00" datetime="2018-04-26T16:00:00.000Z"  itemprop="datePublished">2018-04-27</time>

            


            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h1 id="混合加密的理由"><a href="#混合加密的理由" class="headerlink" title="混合加密的理由"></a>混合加密的理由</h1><ul>
<li>由于随着计算机系统能力的不断发展，DES的安全性比它刚出现时会弱得多，追溯历史破解DES的案例层出不穷，一台实际的机器可以在数天内破解DES是让某些人相信他们不能依赖DES的安全性的唯一方法。而相对于DES，RSA的安全性则相对高些，虽然破解RSA的案例也有，但其所付出的代价是相对大的(相对DES)，如今RSA的密钥也在升级，这说明破解RSA的难度也在增大。</li>
<li>在RSA加解密算法中提及到RSA加密明文会受密钥的长度限制，这就说明用RSA加密的话明文长度是有限制的，而在实际情况我们要进行加密的明文长度或许会大于密钥长度，这样一来我们就不得不舍去RSA加密了。对此，DES加密则没有此限制。</li>
</ul>
<p>鉴于以上两点(个人观点)，单独的使用DES或RSA加密可能没有办法满足实际需求，所以就采用了RSA和DES加密方法相结合的方式来实现数据的加密。</p>
<h1 id="实现方式"><a href="#实现方式" class="headerlink" title="实现方式"></a>实现方式</h1><ol>
<li>发送方使用DES密钥加密信息(明文)。</li>
</ol>
<ol start="2">
<li>发送方使用接收方的RSA公钥加密前面的DES密钥串信息。</li>
</ol>
<p>　最终将混合信息进行传递。</p>
<p>　而接收方接收到信息后：</p>
<ol>
<li>接收方自己的用RSA私钥解密DES密钥信息。</li>
<li>再用RSA解密获取到的密钥信息解密密文信息。</li>
</ol>
<p>　　最终就可以得到我们要的信息(明文)。</p>
<h1 id="实现例子"><a href="#实现例子" class="headerlink" title="实现例子"></a>实现例子</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">/// &lt;summary&gt;</span><br><span class="line">/// RSA和DES混合加密</span><br><span class="line">/// &lt;/summary&gt;</span><br><span class="line">/// &lt;param name=&quot;data&quot;&gt;待加密数据&lt;/param&gt;</span><br><span class="line">/// &lt;param name=&quot;publicKey&quot;&gt;RSA公钥&lt;/param&gt;</span><br><span class="line">/// &lt;returns&gt;&lt;/returns&gt;</span><br><span class="line">public Param Encrypt(string data, string publicKey)</span><br><span class="line">&#123;</span><br><span class="line">    //加密数据</span><br><span class="line">    DESSecurity DES = new DESSecurity();</span><br><span class="line">    string DESKey = DES.GenerateKey();</span><br><span class="line">    string encryptData = DES.Encrypt(data, DESKey);</span><br><span class="line"></span><br><span class="line">    //加密DESkey</span><br><span class="line">    RSASecurity RSA = new RSASecurity();</span><br><span class="line">    string encryptDESKey = RSA.Encrypt(DESKey, publicKey);</span><br><span class="line"></span><br><span class="line">    Param mixParam = new Param();</span><br><span class="line">    mixParam.DESKey = encryptDESKey;</span><br><span class="line">    mixParam.Data = encryptData;</span><br><span class="line">    return mixParam;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/// &lt;summary&gt;</span><br><span class="line">/// RSA和DES混合解密</span><br><span class="line">/// &lt;/summary&gt;</span><br><span class="line">/// &lt;param name=&quot;data&quot;&gt;待解密数据&lt;/param&gt;</span><br><span class="line">/// &lt;param name=&quot;key&quot;&gt;带解密的DESKey&lt;/param&gt;</span><br><span class="line">/// &lt;param name=&quot;privateKey&quot;&gt;RSA私钥&lt;/param&gt;</span><br><span class="line">/// &lt;returns&gt;&lt;/returns&gt;</span><br><span class="line">public string Decrypt(string data, string key, string privateKey)</span><br><span class="line">&#123;</span><br><span class="line">    //解密DESKey</span><br><span class="line">    RSASecurity RSA = new RSASecurity();</span><br><span class="line">    string DESKey = RSA.Decrypt(key, privateKey);</span><br><span class="line"></span><br><span class="line">    //解密数据</span><br><span class="line">    DESSecurity DES = new DESSecurity();</span><br><span class="line">    return DES.Decrypt(data, DESKey);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

        </div>

        <blockquote class="post-copyright">
    
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2018-04-28T15:45:00.000Z" itemprop="dateUpdated">2018-04-28 23:45:00</time>
</span><br>


        
        原文链接：<a href="/blog/2018/04/27/混合加密算法(RSA和DES).html" target="_blank" rel="external">http://aixiaodenanhai.gitee.io/blog/2018/04/27/混合加密算法(RSA和DES).html</a>
        
    </div>
    
    <footer>
        <a href="http://aixiaodenanhai.gitee.io/blog">
            <img src="/blog/img/avatar.jpg" alt="何俊鑫">
            何俊鑫
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog/tags/网络安全/">网络安全</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://aixiaodenanhai.gitee.io/blog/2018/04/27/混合加密算法(RSA和DES).html&title=《混合加密算法(RSA和DES)》 — Junxin's Blog&pic=http://aixiaodenanhai.gitee.io/blog/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://aixiaodenanhai.gitee.io/blog/2018/04/27/混合加密算法(RSA和DES).html&title=《混合加密算法(RSA和DES)》 — Junxin's Blog&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://aixiaodenanhai.gitee.io/blog/2018/04/27/混合加密算法(RSA和DES).html" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《混合加密算法(RSA和DES)》 — Junxin's Blog&url=http://aixiaodenanhai.gitee.io/blog/2018/04/27/混合加密算法(RSA和DES).html&via=http://aixiaodenanhai.gitee.io/blog" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://aixiaodenanhai.gitee.io/blog/2018/04/27/混合加密算法(RSA和DES).html" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/blog/2018/04/27/RSA的公钥和私钥的使用详解.html" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">RSA的公钥和私钥的使用详解</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/blog/2018/04/10/IDEA将已有项目添加到git.html" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">IDEA将已有项目添加到git</h4>
      </a>
    </div>
  
</nav>



    

















</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        谢谢打赏.
        <i class="icon icon-quote-right"></i>
    </h3>
    <div class="reward-content">
        
        <div class="reward-code">
            <img id="rewardCode" src="/blog/img/wechat.png" alt="打赏二维码">
        </div>
        
        <label class="reward-toggle">
            <input id="rewardToggle" type="checkbox" class="reward-toggle-check"
                data-wechat="/blog/img/wechat.png" data-alipay="/blog/img/alipay.png">
            <div class="reward-toggle-ctrol">
                <span class="reward-toggle-item wechat">微信</span>
                <span class="reward-toggle-label"></span>
                <span class="reward-toggle-item alipay">支付宝</span>
            </div>
        </label>
        
    </div>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/blog/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循 <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p><span>何俊鑫 &copy; 2015 - 2018</span>
            <span>
                
                Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
            </span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://aixiaodenanhai.gitee.io/blog/2018/04/27/混合加密算法(RSA和DES).html&title=《混合加密算法(RSA和DES)》 — Junxin's Blog&pic=http://aixiaodenanhai.gitee.io/blog/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://aixiaodenanhai.gitee.io/blog/2018/04/27/混合加密算法(RSA和DES).html&title=《混合加密算法(RSA和DES)》 — Junxin's Blog&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://aixiaodenanhai.gitee.io/blog/2018/04/27/混合加密算法(RSA和DES).html" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《混合加密算法(RSA和DES)》 — Junxin's Blog&url=http://aixiaodenanhai.gitee.io/blog/2018/04/27/混合加密算法(RSA和DES).html&via=http://aixiaodenanhai.gitee.io/blog" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://aixiaodenanhai.gitee.io/blog/2018/04/27/混合加密算法(RSA和DES).html" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/blog/', SHARE: true, REWARD: true };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = '死鬼去哪里了！';
            clearTimeout(titleTime);
        } else {
            document.title = '(つェ⊂)咦!又好了!';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



</body>
</html>
